##! /bin/bash
#! bash
#
#  $Id: stats.sh 3 2010-05-27 16:25:49Z alistair.mills@btinternet.com $
#
export TARGET='Articles de La Guinguette - Statistiques'

. ./defines.sh

export   total=0
export    last=.last/
export    date=`date +'%A %d %B %Y'`

export alanb_arts_done=0
export alanb_arts_prom=0
export alanb_word_done=0
export alanb_word_prom=0

export alist_arts_done=0
export alist_arts_prom=0
export alist_word_done=0
export alist_word_prom=0

export anyyy_arts_done=0
export anyyy_arts_prom=0
export anyyy_word_done=0
export anyyy_word_prom=0

export cathy_arts_done=0
export cathy_arts_prom=0
export cathy_word_done=0
export cathy_word_prom=0

export chris_arts_done=0
export chris_arts_prom=0
export chris_word_done=0
export chris_word_prom=0

export donna_arts_done=0
export donna_arts_prom=0
export donna_word_done=0
export donna_word_prom=0

export lorii_arts_done=0
export lorii_arts_prom=0
export lorii_word_done=0
export lorii_word_prom=0

export louis_arts_done=0
export louis_arts_prom=0
export louis_word_done=0
export louis_word_prom=0

export richd_arts_done=0
export richd_arts_prom=0
export richd_word_done=0
export richd_word_prom=0

export rober_arts_done=0
export rober_arts_prom=0
export rober_word_done=0
export rober_word_prom=0

export ryan_arts_done=0
export ryan_arts_prom=0
export ryan_word_done=0
export ryan_word_prom=0

export total_arts_done=0
export total_arts_prom=0
export total_word_done=0
export total_word_prom=0

export anon_arts_done=0
export anon_arts_prom=0
export anon_word_done=0
export anon_word_prom=0


cat > $2 <</eof

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <title>$TARGET</title>
      <link rel="shortcut icon" href="$TARGET.ico" type="image/x-icon">
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <link href="../../style.css" rel="stylesheet" type="text/css">
      <script src="sorttable.js" language="JavaScript" type="text/javascript"></script>

      </head>

   <body background="../back.gif" lang="FR">

<a href="index.html"><img src="../../up.gif" alt="up" width="36" height="18"></a>

<h1>Articles de La Guinguette &agrave; traduire </h1>

<p>Cliquer sur le titre d'un colon pour tirer les donn&eacute;es du tableau.</p>

<table class="sortable" border="1">

<thead>
<tr>
<th align="left"><u>Translator</u></th>

<th align="left"><u>Articles</u></th>
<th align="left"><u>Articles Promised</u></th>

<th align="left"><u>Words</u></th>
<th align="left"><u>Words Promised</u></th>
</tr>
</thead>

<tbody>

/eof


### Main script stars here ###
# Store file name  here
FILE=$1
export prepare='<font color="#a0a0a0"> On la pr&eacute;pare </font>'
  . ./defines.sh
  . ./keys.sh

while read year mon cat size url key trans line
do

  if [ "$line" != "$title_line" -a "$year" != "$comment_line" ]
   then
      . ./categories.sh
      . ./months.sh
      . ./translators.sh
      export tra=${year}_${mon}_${cat}
      if [ "$line" != "" ]
         then
         export       total=`expr $total + 1`
         export         tot=`printf '%.3i' $total`

         echo $tot - $line

         export total_arts_done=`expr $total_arts_done + 1`
         export total_arts_prom=0
         export total_word_done=`expr $total_word_done + $size`
         export total_word_prom=0

            [ "$key" = "$done" ]             && export anyyy_arts_done=`expr $anyyy_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export anyyy_arts_prom=`expr $anyyy_arts_prom + 1`
            [ "$key" = "$done" ]             && export anyyy_word_done=`expr $anyyy_word_done + $size`
            [ "$key" = "$in_progress" ]      && export anyyy_word_prom=`expr $anyyy_word_prom + $size`

         if [ "$trans" = "alan" ]
         then
            [ "$key" = "$done" ]             && export alanb_arts_done=`expr $alanb_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export alanb_arts_prom=`expr $alanb_arts_prom + 1`
            [ "$key" = "$done" ]             && export alanb_word_done=`expr $alanb_word_done + $size`
            [ "$key" = "$in_progress" ]      && export alanb_word_prom=`expr $alanb_word_prom + $size`
         fi

         if [ "$trans" = "alistair" ]
         then
            [ "$key" = "$done" ]             && export alist_arts_done=`expr $alist_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export alist_arts_prom=`expr $alist_arts_prom + 1`
            [ "$key" = "$done" ]             && export alist_word_done=`expr $alist_word_done + $size`
            [ "$key" = "$in_progress" ]      && export alist_word_prom=`expr $alist_word_prom + $size`
         fi

         if [ "$trans" = "catherine" ]
         then
            [ "$key" = "$done" ]             && export cathy_arts_done=`expr $cathy_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export cathy_arts_prom=`expr $cathy_arts_prom + 1`
            [ "$key" = "$done" ]             && export cathy_word_done=`expr $cathy_word_done + $size`
            [ "$key" = "$in_progress" ]      && export cathy_word_prom=`expr $cathy_word_prom + $size`
         fi

         if [ "$trans" = "chris" ]
         then
            [ "$key" = "$done" ]             && export chris_arts_done=`expr $chris_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export chris_arts_prom=`expr $chris_arts_prom + 1`
            [ "$key" = "$done" ]             && export chris_word_done=`expr $chris_word_done + $size`
            [ "$key" = "$in_progress" ]      && export chris_word_prom=`expr $chris_word_prom + $size`
         fi

         if [ "$trans" = "donna" ]
         then
            [ "$key" = "$done" ]             && export donna_arts_done=`expr $donna_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export donna_arts_prom=`expr $donna_arts_prom + 1`
            [ "$key" = "$done" ]             && export donna_word_done=`expr $donna_word_done + $size`
            [ "$key" = "$in_progress" ]      && export donna_word_prom=`expr $donna_word_prom + $size`
         fi

         if [ "$trans" = "lori" ]
         then
            [ "$key" = "$done" ]             && export lorii_arts_done=`expr $lorii_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export lorii_arts_prom=`expr $lorii_arts_prom + 1`
            [ "$key" = "$done" ]             && export lorii_word_done=`expr $lorii_word_done + $size`
            [ "$key" = "$in_progress" ]      && export lorii_word_prom=`expr $lorii_word_prom + $size`
         fi

         if [ "$trans" = "louise" ]
         then
            [ "$key" = "$done" ]             && export louis_arts_done=`expr $louis_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export louis_arts_prom=`expr $louis_arts_prom + 1`
            [ "$key" = "$done" ]             && export louis_word_done=`expr $louis_word_done + $size`
            [ "$key" = "$in_progress" ]      && export louis_word_prom=`expr $louis_word_prom + $size`
         fi

         if [ "$trans" = "richard" ]
         then
            [ "$key" = "$done" ]             && export richd_arts_done=`expr $richd_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export richd_arts_prom=`expr $richd_arts_prom + 1`
            [ "$key" = "$done" ]             && export richd_word_done=`expr $richd_word_done + $size`
            [ "$key" = "$in_progress" ]      && export richd_word_prom=`expr $richd_word_prom + $size`
         fi

         if [ "$trans" = "robert" ]
         then
            [ "$key" = "$done" ]             && export rober_arts_done=`expr $rober_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export rober_arts_prom=`expr $rober_arts_prom + 1`
            [ "$key" = "$done" ]             && export rober_word_done=`expr $rober_word_done + $size`
            [ "$key" = "$in_progress" ]      && export rober_word_prom=`expr $rober_word_prom + $size`
         fi

         if [ "$trans" = "ryan" ]
         then
            [ "$key" = "$done" ]             && export ryan_arts_done=`expr $ryan_arts_done + 1`
            [ "$key" = "$in_progress" ]      && export ryan_arts_prom=`expr $ryan_arts_prom + 1`
            [ "$key" = "$done" ]             && export ryan_word_done=`expr $ryan_word_done + $size`
            [ "$key" = "$in_progress" ]      && export ryan_word_prom=`expr $ryan_word_prom + $size`
         fi

         if [ "$trans" = "unknown" ]
         then
                                                export anon_arts_done=`expr $anon_arts_done + 1`
                                                export anon_word_done=`expr $anon_word_done + $size`
         fi

      fi
   fi
done < $FILE


        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">total</td>'                                                                  >> $2
        echo '<td align="right">'$total_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$total_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$total_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$total_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">any</td>'                                                                    >> $2
        echo '<td align="right">'$anyyy_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$anyyy_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$anyyy_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$anyyy_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">alan</td>'                                                                   >> $2
        echo '<td align="right">'$alanb_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$alanb_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$alanb_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$alanb_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">alistair</td>'                                                               >> $2
        echo '<td align="right">'$alist_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$alist_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$alist_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$alist_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">catherine</td>'                                                              >> $2
        echo '<td align="right">'$cathy_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$cathy_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$cathy_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$cathy_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">donna</td>'                                                                  >> $2
        echo '<td align="right">'$donna_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$donna_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$donna_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$donna_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">chris</td>'                                                                  >> $2
        echo '<td align="right">'$chris_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$chris_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$chris_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$chris_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">lori</td>'                                                                   >> $2
        echo '<td align="right">'$lorii_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$lorii_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$lorii_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$lorii_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">louise</td>'                                                                 >> $2
        echo '<td align="right">'$louis_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$louis_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$louis_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$louis_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">richard</td>'                                                                >> $2
        echo '<td align="right">'$richd_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$richd_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$richd_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$richd_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">robert</td>'                                                                 >> $2
        echo '<td align="right">'$rober_arts_done'</td>'                                                    >> $2
        echo '<td align="right">'$rober_arts_prom'</td>'                                                    >> $2
        echo '<td align="right">'$rober_word_done'</td>'                                                    >> $2
        echo '<td align="right">'$rober_word_prom'</td>'                                                    >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">ryan</td>'                                                                   >> $2
        echo '<td align="right">'$ryan_arts_done'</td>'                                                     >> $2
        echo '<td align="right">'$ryan_arts_prom'</td>'                                                     >> $2
        echo '<td align="right">'$ryan_word_done'</td>'                                                     >> $2
        echo '<td align="right">'$ryan_word_prom'</td>'                                                     >> $2
        echo '</tr>'                                                                                        >> $2

        echo '<tr>'                                                                                         >> $2
        echo '<td align="left">unknown</td>'                                                                >> $2
        echo '<td align="right">'$anon_arts_done'</td>'                                                     >> $2
        echo '<td align="right">'$anon_arts_prom'</td>'                                                     >> $2
        echo '<td align="right">'$anon_word_done'</td>'                                                     >> $2
        echo '<td align="right">'$anon_word_prom'</td>'                                                     >> $2
        echo '</tr>'                                                                                        >> $2

cat >> $2 <</eof
</tbody>
</table>

<hr>
      <p lang="ENS">With questions or for more information, please contact Alistair Mills <a href="mailto:alistair.mills@btinternet.com"> alistair.mills@btinternet.com</a><br>
      Updated <!-- #BeginDate format:Sw1 --> $date <!-- #EndDate --></p>
      <hr>
      <a href="http://validator.w3.org/check?uri=referer">
        <img
        src="http://www.w3.org/Icons/valid-html401-blue"
        alt="Valid HTML 4.01 Transitional" height="31" width="88">
      </a>
<hr>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2273668-1";
urchinTracker();
</script>

      </body>
</html>
/eof

cat > $3 <</eof
"alan";$alanb_arts_done;$alanb_word_done
"alistair";$alist_arts_done;$alist_word_done
"any";$anyyy_arts_done;$anyyy_word_done
"catherine";$cathy_arts_done;$cathy_word_done
"chris";$chris_arts_done;$chris_word_done
"donna";$donna_arts_done;$donna_word_done
"lori";$lorii_arts_done;$lorii_word_done
"louise";$louis_arts_done;$louis_word_done
"richard";$richd_arts_done;$richd_word_done
"robert";$rober_arts_done;$rober_word_done
"ryan";$ryan_arts_done;$ryan_word_done
"total";$total_arts_done;$total_word_done
"unknown";$unknown_arts_done;$unknown_word_done
/eof

#
#
#
